
/*
 * Copyright 2002-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2021原作者。
 *
 *根据Apache许可证2.0版（“许可证”）获得许可；
 *除非符合许可证，否则不得使用此文件。
 *您可以在以下地址获取许可证副本：
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证分发的内容是按“原样”分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限和
 *许可证下的限制。
 */

package org.springframework.aop.framework;

import java.io.Serializable;

import org.springframework.util.Assert;

/**
 * Convenience superclass for configuration used in creating proxies,
 * to ensure that all proxy creators have consistent properties.
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 * @see AdvisedSupport
 */
/**
 *用于创建代理的配置的便利超类，
 *确保所有代理创建者具有一致的财产。
 *
 *@作者Rod Johnson
 *@作者Juergen Hoeller
 *@参见建议支持
 */
public class ProxyConfig implements Serializable {

	/** use serialVersionUID from Spring 1.2 for interoperability. */
	private static final long serialVersionUID = -8409359707199703185L;


	private boolean proxyTargetClass = false;

	private boolean optimize = false;

	boolean opaque = false;

	boolean exposeProxy = false;

	private boolean frozen = false;


	/**
	 * Set whether to proxy the target class directly, instead of just proxying
	 * specific interfaces. Default is "false".
	 * <p>Set this to "true" to force proxying for the TargetSource's exposed
	 * target class. If that target class is an interface, a JDK proxy will be
	 * created for the given interface. If that target class is any other class,
	 * a CGLIB proxy will be created for the given class.
	 * <p>Note: Depending on the configuration of the concrete proxy factory,
	 * the proxy-target-class behavior will also be applied if no interfaces
	 * have been specified (and no interface autodetection is activated).
	 * @see org.springframework.aop.TargetSource#getTargetClass()
	 */
	/** use serialVersionUID from Spring 1.2 for interoperability. */
	私有静态最终长序列版本UID=-840935907199703185L；


	private boolean proxyTargetClass=false；

	私有布尔优化=false；

	布尔不透明=假；

	布尔exposeProxy=false；

	私有布尔冻结=false；


	/**
	 *设置是否直接代理目标类，而不仅仅是代理
	 *特定接口。默认值为“false”。
	 *<p>将此设置为“true”以强制代理TargetSource的已暴露
	 *目标类。如果目标类是接口，则JDK代理将
	 *为给定接口创建。如果该目标类是任何其他类，
	 *将为给定类创建CGLIB代理。
	 *＜p＞注意：根据具体代理工厂的配置，
	 *如果没有接口，也将应用代理目标类行为
	 *已指定（且未激活接口自动检测）。
	 *@see org.springframework.aop.TargetSource#getTargetClass（）
	 */
	public void setProxyTargetClass(boolean proxyTargetClass) {
		this.proxyTargetClass = proxyTargetClass;
	}

	/**
	 * Return whether to proxy the target class directly as well as any interfaces.
	 */
	/**
	 *返回是否直接代理目标类以及任何接口。
	 */
	public boolean isProxyTargetClass() {
		return this.proxyTargetClass;
	}

	/**
	 * Set whether proxies should perform aggressive optimizations.
	 * The exact meaning of "aggressive optimizations" will differ
	 * between proxies, but there is usually some tradeoff.
	 * Default is "false".
	 * <p>With Spring's current proxy options, this flag effectively
	 * enforces CGLIB proxies (similar to {@link #setProxyTargetClass})
	 * but without any class validation checks (for final methods etc).
	 */
	/**
	 *设置代理是否应执行积极优化。
	 *“积极优化”的确切含义将有所不同
	 *代理之间，但通常会有一些折衷。
	 *默认值为“false”。
	 *＜p＞使用Spring当前的代理选项，此标志有效
	 *强制CGLIB代理（类似于｛@link#setProxyTargetClass｝）
	 *但没有任何类验证检查（对于最终方法等）。
	 */
	public void setOptimize(boolean optimize) {
		this.optimize = optimize;
	}

	/**
	 * Return whether proxies should perform aggressive optimizations.
	 */
	/**
	 *返回代理是否应执行积极优化。
	 */
	public boolean isOptimize() {
		return this.optimize;
	}

	/**
	 * Set whether proxies created by this configuration should be prevented
	 * from being cast to {@link Advised} to query proxy status.
	 * <p>Default is "false", meaning that any AOP proxy can be cast to
	 * {@link Advised}.
	 */
	/**
	 *设置是否应阻止此配置创建的代理
	 *从强制转换到｛@linkAdvised｝以查询代理状态。
	 *＜p＞默认值为“false”，这意味着任何AOP代理都可以被强制转换为
	 *｛@link已建议｝。
	 */
	public void setOpaque(boolean opaque) {
		this.opaque = opaque;
	}

	/**
	 * Return whether proxies created by this configuration should be
	 * prevented from being cast to {@link Advised}.
	 */
	/**
	 *返回此配置创建的代理是否应
	 *无法强制转换为｛@link Advised｝。
	 */
	public boolean isOpaque() {
		return this.opaque;
	}

	/**
	 * Set whether the proxy should be exposed by the AOP framework as a
	 * ThreadLocal for retrieval via the AopContext class. This is useful
	 * if an advised object needs to call another advised method on itself.
	 * (If it uses {@code this}, the invocation will not be advised).
	 * <p>Default is "false", in order to avoid unnecessary extra interception.
	 * This means that no guarantees are provided that AopContext access will
	 * work consistently within any method of the advised object.
	 */
	/**
	 *设置AOP框架是否应将代理公开为
	 *ThreadLocal用于通过AopContext类进行检索。这很有用
	 *如果被建议的对象需要在其自身上调用另一个被建议的方法。
	 *（如果它使用｛@code this｝，则不会通知调用）。
	 *＜p＞默认值为“false”，以避免不必要的额外拦截。
	 *这意味着不保证AopContext访问将
	 *在建议对象的任何方法内始终工作。
	 */
	public void setExposeProxy(boolean exposeProxy) {
		this.exposeProxy = exposeProxy;
	}

	/**
	 * Return whether the AOP proxy will expose the AOP proxy for
	 * each invocation.
	 */
	/**
	 *返回AOP代理是否将为
	 *每次调用。
	 */
	public boolean isExposeProxy() {
		return this.exposeProxy;
	}

	/**
	 * Set whether this config should be frozen.
	 * <p>When a config is frozen, no advice changes can be made. This is
	 * useful for optimization, and useful when we don't want callers to
	 * be able to manipulate configuration after casting to Advised.
	 */
	/**
	 *设置是否应冻结此配置。
	 *＜p＞当配置被冻结时，无法进行建议更改。这是
	 *对优化有用，当我们不希望调用方
	 *能够在转换为Advised后操纵配置。
	 */
	public void setFrozen(boolean frozen) {
		this.frozen = frozen;
	}

	/**
	 * Return whether the config is frozen, and no advice changes can be made.
	 */
	/**
	 *返回配置是否已冻结，并且无法进行任何建议更改。
	 */
	public boolean isFrozen() {
		return this.frozen;
	}


	/**
	 * Copy configuration from the other config object.
	 * @param other object to copy configuration from
	 */
	/**
	 *从其他配置对象复制配置。
	 *@param要从中复制配置的其他对象
	 */
	public void copyFrom(ProxyConfig other) {
		Assert.notNull(other, "Other ProxyConfig object must not be null");
		this.proxyTargetClass = other.proxyTargetClass;
		this.optimize = other.optimize;
		this.exposeProxy = other.exposeProxy;
		this.frozen = other.frozen;
		this.opaque = other.opaque;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("proxyTargetClass=").append(this.proxyTargetClass).append("; ");
		sb.append("optimize=").append(this.optimize).append("; ");
		sb.append("opaque=").append(this.opaque).append("; ");
		sb.append("exposeProxy=").append(this.exposeProxy).append("; ");
		sb.append("frozen=").append(this.frozen);
		return sb.toString();
	}

}
